package com.caijing.caijingxueyuanxd.controller;

import com.caijing.caijingxueyuanxd.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
public class ImageController {
    @Autowired
    private  ImageService imageService;

    /**
     * 获取所有图片路径
     */
    @GetMapping("/images/paths")
    public ResponseEntity<List<String>> getImagePaths() throws IOException {
        return ResponseEntity.ok(imageService.getAllImagePaths());
    }

    /**
     * 获取图片详细信息
     */
    @GetMapping("/images/details")
    public ResponseEntity<List<Map<String, String>>> getImageDetails() throws IOException {
        return ResponseEntity.ok(imageService.getImageDetails());
    }

    /**
     * 获取图片数量统计
     */
    @GetMapping("/images/count")
    public ResponseEntity<String> getImageCount() throws IOException {
        List<String> paths = imageService.getAllImagePaths();
        return ResponseEntity.ok("共发现 " + paths.size() + " 张图片");
    }
}